app.controller('couponsDetailAddCtrl',['$scope','$state','toaster','couponsDetailAddService',function($scope,$state,toaster,couponsDetailAddService){

    $scope.couponsDetailAddService=couponsDetailAddService;

    $scope.addCoupons=function(){
        couponsDetailAddService.addCoupons($scope).then(function(result){
            switch (result.status){
                case 200:
                    toaster.pop('success', "提示", "操作成功");
                    $state.go('app.coupons');
                    couponsDetailAddService.init();
                    break;
                case 624:
                case 734:
                    toaster.pop('waiting', "提示", result.message);
                    $state.go('app.404');
                    break;
                default :
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break;
            }
        })
    }

}]);